import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource

def generate_launch_description():
    # 获取包共享目录
    bringup_dir = get_package_share_directory('rm_bringup')

    # 加载 robot_state_publisher
    robot_gimbal_description = os.path.join(bringup_dir, 'launch', 'robot_gimbal.launch.py')

    # 加载第一个命名空间的 launch 文件
    bringup_first_launch = os.path.join(bringup_dir, 'launch', 'bringup_first.launch.py')

    # 加载第二个命名空间的 launch 文件
    bringup_second_launch = os.path.join(bringup_dir, 'launch', 'bringup_second.launch.py')

    # 创建 launch 描述
    launch_description_list = [
        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(robot_gimbal_description)
        ),
        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(bringup_first_launch)
        ),
        IncludeLaunchDescription(
            PythonLaunchDescriptionSource(bringup_second_launch)
        ),
    ]

    return LaunchDescription(launch_description_list)